package com.nmsl.controller;
import com.nmsl.domain.GyfRegistrationManagement;
import com.nmsl.mapper.GyfRegistrationManagementMapper;
import com.nmsl.util.R.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/rm")
public class gyf_RegistrationManagementController {
    @Autowired
    private GyfRegistrationManagementMapper mapper;
    //动态的插入挂号管理的数据

    @PostMapping("/insert")
    public R insert(@RequestBody GyfRegistrationManagement rm){
        System.out.println("打印一下传来的参数");
        System.out.println(rm);

        int insert = mapper.insert(rm);
        if(insert>0){
            return R.ok(rm.getRegistrationId());
        }else{
            return R.fail("插入失败");
        }
    }

    //通过挂号管理id查询这条挂号信息
    @GetMapping("/selectByid")
    public R selectByid(int registrationId){
        GyfRegistrationManagement gyfRegistrationManagement = mapper.selectByPrimaryKey(registrationId);
        if(gyfRegistrationManagement!=null){
            return R.ok(gyfRegistrationManagement);
        }else{
            return R.fail("查询失败");
        }
    }
}
